import Page
from Page import Map
from Base.Base import Base
from selenium.webdriver.common.by import By


class MapSearchPage(Base):
    """
    搜索页面

    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 左侧的home键
        self.search_home_btn = (By.XPATH, Map.RESOURCE_ID.format("rl_navigation_home"))

        # 左侧的返回键
        self.search_back_btn = (By.XPATH, Map.RESOURCE_ID.format('rl_navigation_back'))

        # 当前定位
        self.search_positioning_text = (By.XPATH, Map.RESOURCE_ID.format("search_city"))

        # 搜索框
        self.search_bar_input = (By.XPATH, Map.RESOURCE_ID.format("tv_search_input"))

        # 去过按钮
        self.search_been_there_btn = (By.XPATH, Map.RESOURCE_ID.format("btn0"))

        # 搜过按钮
        self.search_searched_btn = (By.XPATH, Map.RESOURCE_ID.format("btn1"))

        # 收藏按钮
        self.search_collect_btn = (By.XPATH, Map.RESOURCE_ID.format("btn2"))

        # 回家按钮
        self.search_go_home_btn = (By.XPATH, Map.RESOURCE_ID.format("btn_home"))

        # 去公司按钮
        self.search_go_company_btn = (By.XPATH, Map.RESOURCE_ID.format("btn_company"))

        # 搜附近
        self.search_nearby_btn = (By.XPATH, Map.RESOURCE_ID.format("btn_around_search"))

        # 加油站
        self.search_gas_btn = (By.XPATH, Map.RESOURCE_ID.format("btn_oil"))

        # 银行
        self.search_bank_btn = (By.XPATH, Map.RESOURCE_ID.format("btn_bank"))

        # 美食
        self.search_food_btn = (By.XPATH, Map.RESOURCE_ID.format("btn_food"))

        # 停车场
        self.search_park_btn = (By.XPATH, Map.RESOURCE_ID.format("btn_park"))

        # 更多
        self.search_more_btn = (By.XPATH, Map.RESOURCE_ID.format("btn_more"))

        # 暂无历史记录
        self.search_no_record_text = (By.XPATH, Map.RESOURCE_ID.format("tv_text"))

    def click_home(self):
        """
        点击左侧的home键

        :return:None
        """
        self.click_element(self.search_home_btn)

    def click_back(self):
        """
        点击左侧的back键

        :return:None
        """
        self.click_element(self.search_back_btn)

    def get_positioning(self):
        """
        获取当前定位

        :return:获取元素
        """
        return self.find_element_o(self.search_positioning_text)

    def input_bar(self, index):
        """
        搜索框输入内容

        index 为默认输入内容
        :return:输入内容
        """
        self.input_text(self.search_bar_input, text=index)

    def click_bar(self):
        """
        点击搜索框

        :return:None

        """
        self.click_element(self.search_bar_input)

    def get_been_there_selected(self):
        """
        获取去过属性

        :return:获取元素
        """
        return self.find_element_o(self.search_been_there_btn)

    def click_been_there(self):
        """
        点击去过按钮

        :return:None
        """
        self.click_element(self.search_been_there_btn)

    def click_searched(self):
        """
        点击搜过按钮

        :return:None
        """
        self.click_element(self.search_searched_btn)

    def click_collect(self):
        """
        点击收藏按钮

        :return:None
        """
        self.click_element(self.search_collect_btn)

    def click_go_home(self):
        """
        点击回家按钮

        :return:None
        """
        self.click_element(self.search_go_home_btn)

    def click_go_company(self):
        """
        点击公司按钮

        :return:None
        """
        self.click_element(self.search_go_company_btn)

    def click_gas(self):
        """
        点击搜加油站按钮

        :return:None
        """
        self.click_element(self.search_gas_btn)

    def click_bank(self):
        """
        点击搜银行按钮

        :return:None
        """
        self.click_element(self.search_bank_btn)

    def click_food(self):
        """
        点击搜美食按钮

        :return:None
        """
        self.click_element(self.search_food_btn)

    def click_park(self):
        """
        点击搜停车场按钮

        :return:None
        """
        self.click_element(self.search_park_btn)

    def click_more(self):
        """
        点击更多按钮

        :return:None
        """
        self.click_element(self.search_more_btn)

    def get_no_record(self):
        """
        获取暂无历史纪录文案

        :return:获取元素
        """
        return self.find_element_o(self.search_no_record_text)

    def is_display_map_search(self):
        """
        查看是否进入地图搜索页

        :return:
        """
        return self.is_display(self.search_go_home_btn)
